package com.sso.util;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class PageUtil implements java.io.Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 4599136585848947979L;
	protected final transient Log log = LogFactory.getLog(PageUtil.class);
	//private String thePage;
	private int currentPage = 1;
	private int nextPage = 1;
	private int maxRow = 0;
	private int prePage = 1;
	private int totalPage = 1;
	private int pageSize = 10;
	private List dataSet = null;
	private int currentPage2 = -1;
	
	
	/*
	public String getThePage() {
		return thePage;
	}
	public void setThePage(String thePage) {
		this.thePage = thePage;
	}
	*/
	
	public int getCurrentPage2() {
		return currentPage2;
	}
	public void setCurrentPage2(int currentPage2) {
		this.currentPage2 = currentPage2;
	}
	public int getCurrentPage() {
//		if(this.thePage != null && this.thePage.trim().length() > 0) {
//			log.debug(" --------------------- the page:" + thePage);
//			if(this.thePage.contains(",")) {
//				this.currentPage = Integer.parseInt(this.thePage.substring(0,this.thePage.indexOf(",")));
//			}
//		}
		if(this.currentPage2 > 0) {
			return this.currentPage2;
		}
		return currentPage;
	}
	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}
	public int getNextPage() {
		return nextPage;
	}
	public void setNextPage(int nextPage) {
		this.nextPage = nextPage;
	}
	public int getMaxRow() {
		return maxRow;
	}
	public void setMaxRow(int maxRow) {
		this.maxRow = maxRow;
	}
	public int getPrePage() {
		return prePage;
	}
	public void setPrePage(int prePage) {
		this.prePage = prePage;
	}
	public int getTotalPage() {
		if(this.maxRow > 0) {
			int y = this.maxRow%this.pageSize;
			totalPage = this.maxRow/this.pageSize;
			if(y!=0) {
				totalPage++;
			}
		}
		return totalPage;
	}
	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public List getDataSet() {
		return dataSet;
	}
	public void setDataSet(List dataSet) {
		this.dataSet = dataSet;
	}
}
